{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Boston Housing Data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A function that loads the `boston_housing_data` dataset into NumPy arrays."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> from mlxtend.data import boston_housing_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Overview"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The Boston Housing dataset for regression analysis.\n",
    "\n",
    "**Features**\n",
    "\n",
    "1. CRIM:      per capita crime rate by town\n",
    "2. ZN:        proportion of residential land zoned for lots over 25,000 sq.ft.\n",
    "3. INDUS:     proportion of non-retail business acres per town\n",
    "4. CHAS:      Charles River dummy variable (= 1 if tract bounds river; 0 otherwise)\n",
    "5. NOX:       nitric oxides concentration (parts per 10 million)\n",
    "6. RM:        average number of rooms per dwelling\n",
    "7. AGE:       proportion of owner-occupied units built prior to 1940\n",
    "8. DIS:       weighted distances to five Boston employment centres\n",
    "9. RAD:       index of accessibility to radial highways\n",
    "10. TAX:      full-value property-tax rate per $10,000\n",
    "11. PTRATIO:  pupil-teacher ratio by town\n",
    "12. B:        1000(Bk - 0.63)^2 where Bk is the proportion of b. by town\n",
    "13. LSTAT:    % lower status of the population\n",
    "    \n",
    "\n",
    "- Number of samples: 506\n",
    "\n",
    "- Target variable (continuous): MEDV, Median value of owner-occupied homes in $1000's\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### References\n",
    "\n",
    "- Source: [https://archive.ics.uci.edu/ml/datasets/Wine](https://archive.ics.uci.edu/ml/datasets/Wine)\n",
    "- Harrison, D. and Rubinfeld, D.L. \n",
    "'Hedonic prices and the demand for clean air', J. Environ. Economics & Management, vol.5, 81-102, 1978."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 - Dataset overview"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(506, 14)\n",
      "Dimensions: 506 x 13\n",
      "1st row [  6.32000000e-03   1.80000000e+01   2.31000000e+00   0.00000000e+00\n",
      "   5.38000000e-01   6.57500000e+00   6.52000000e+01   4.09000000e+00\n",
      "   1.00000000e+00   2.96000000e+02   1.53000000e+01   3.96900000e+02\n",
      "   4.98000000e+00]\n"
     ]
    }
   ],
   "source": [
    "from mlxtend.data import boston_housing_data\n",
    "X, y = boston_housing_data()\n",
    "\n",
    "print('Dimensions: %s x %s' % (X.shape[0], X.shape[1]))\n",
    "print('1st row', X[0])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## API"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "## boston_housing_data\n",
      "\n",
      "*boston_housing_data()*\n",
      "\n",
      "Boston Housing dataset.\n",
      "\n",
      "\n",
      "- `Source` : https://archive.ics.uci.edu/ml/datasets/Housing\n",
      "\n",
      "\n",
      "- `Number of samples` : 506\n",
      "\n",
      "\n",
      "\n",
      "- `Continuous target variable` : MEDV\n",
      "\n",
      "    MEDV = Median value of owner-occupied homes in $1000's\n",
      "\n",
      "    Dataset Attributes:\n",
      "\n",
      "    - 1) CRIM      per capita crime rate by town\n",
      "    - 2) ZN        proportion of residential land zoned for lots over\n",
      "    25,000 sq.ft.\n",
      "    - 3) INDUS     proportion of non-retail business acres per town\n",
      "    - 4) CHAS      Charles River dummy variable (= 1 if tract bounds\n",
      "    river; 0 otherwise)\n",
      "    - 5) NOX       nitric oxides concentration (parts per 10 million)\n",
      "    - 6) RM        average number of rooms per dwelling\n",
      "    - 7) AGE       proportion of owner-occupied units built prior to 1940\n",
      "    - 8) DIS       weighted distances to five Boston employment centres\n",
      "    - 9) RAD       index of accessibility to radial highways\n",
      "    - 10) TAX      full-value property-tax rate per $10,000\n",
      "    - 11) PTRATIO  pupil-teacher ratio by town\n",
      "    - 12) B        1000(Bk - 0.63)^2 where Bk is the prop. of b. by town\n",
      "    - 13) LSTAT    % lower status of the population\n",
      "\n",
      "**Returns**\n",
      "\n",
      "- `X, y` : [n_samples, n_features], [n_class_labels]\n",
      "\n",
      "    X is the feature matrix with 506 housing samples as rows\n",
      "    and 13 feature columns.\n",
      "    y is a 1-dimensional array of the continuous target variable MEDV\n",
      "\n",
      "**Examples**\n",
      "\n",
      "For usage examples, please see\n",
      "    [http://rasbt.github.io/mlxtend/user_guide/data/boston_housing_data/](http://rasbt.github.io/mlxtend/user_guide/data/boston_housing_data/)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "with open('../../api_modules/mlxtend.data/boston_housing_data.md', 'r') as f:\n",
    "    print(f.read())"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  },
  "toc": {
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
